﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows;

namespace Brite.Controls.Tests
{
    public partial class MainWindow
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private const string SmallText = "At vero eos et accusamus et iusto odio dignissimos ducimus.";
        private const string LargeText = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.";

        private const string CodeProjectText =
@"The Code Project was formed to provide developers with a place to meet and exchange ideas.
We hope to provide developers with all the resources they need to help them in their day to day
programming, as well as helping them keep up to date with the latest technologies.
Click on 'Details' for more information.";

        private const string CodeProjectDetailedText =
@"The Code Project is a community of Software development and Design developers joined together
with certain common goals: to learn, to teach and to have fun programming. Developers from all
over the world come together to share source code, tutorials and knowledge for free to help
their fellow programmers.

It is our hope that you find The Code Project to be a wealth of information and a valuable resource.
All we ask is that if you find The Code Project useful, then please share what source code or knowledge
you can in order to give back to the community.

Above and beyond articles and code snippets, The Code Project gives developers a voice. We have
over 3.5 million people reading The Code Project each month, including those from companies such as
Microsoft, Sun, Oracle, and more. The Code Project brings industry and the developer community together.";

        private void onSmallTextOrigClick(object i_sender, RoutedEventArgs i_e)
        {
            var res = MessageBox.Show(this, SmallText, "Small Text", MessageBoxButton.OK, MessageBoxImage.Information);
            MessageBoxEx.Show(String.Format("You clicked on '{0}'.", res), "Result");
        }

        private void onSmallTextNewClick(object i_sender, RoutedEventArgs i_e)
        {
            var res = MessageBoxEx.Show(this, SmallText, "Small Text", MessageBoxExButtons.OK, MessageBoxExIcons.Information);
            MessageBoxEx.Show(this, String.Format("You clicked on '{0}'.", res), "Result");
        }

        private void onLargeTextOrigClick(object i_sender, RoutedEventArgs i_e)
        {
            var res = MessageBox.Show(this, LargeText, "Large Text", MessageBoxButton.YesNoCancel);
            MessageBoxEx.Show(this, String.Format("You clicked on '{0}'.", res), "Result");
        }

        private void onLargeTextNewClick(object i_sender, RoutedEventArgs i_e)
        {
            var res = MessageBoxEx.Show(this, LargeText, "Large Text", MessageBoxExButtons.YesNoCancel);
            MessageBoxEx.Show(this, String.Format("You clicked on '{0}'.", res), "Result");
        }

        private void onCustomClick(object i_sender, RoutedEventArgs i_e)
        {
            var showDetails = new Action(
                () =>
                {
                    var owner = Application.Current.Windows.Cast<Window>().SingleOrDefault(i_wnd => i_wnd.IsActive);
                    MessageBoxEx.Show(owner, CodeProjectDetailedText, "CodeProject Details", MessageBoxExButtons.OK, MessageBoxExIcons.Information);
                }
                );

            var msgBoxInfo = new MessageBoxExInfo();
            msgBoxInfo.Owner = this;
            msgBoxInfo.Text = CodeProjectText;
            msgBoxInfo.Title = "CodeProject";
            msgBoxInfo.IconUri = "pack://application:,,,/MessageBoxExTest;component/codeproject.png";
            msgBoxInfo.Buttons = new List<MessageBoxExButton>
            {
                new MessageBoxExButton("Details", "_Details...", null, showDetails),
                new MessageBoxExButton("Visit", "_Visit", null),
                new MessageBoxExButton("Join", "_Join", true, null, true),
                new MessageBoxExButton("Close", "_Close", false, null, false, false),
            };
            msgBoxInfo.UseOptionCheck = true;
            msgBoxInfo.OptionCheckValue = false;

            var res = MessageBoxEx.Show(msgBoxInfo);
            if (msgBoxInfo.OptionCheckValue == true)
            {
                MessageBoxEx.Show(this, "The option was checked.", "OptionCheckValue");
            }
            switch (res)
            {
                case "Visit":
                    Process.Start("http://www.codeproject.com");
                    break;
                case "Join":
                    Process.Start("http://www.codeproject.com/script/Membership/Modify.aspx");
                    break;
            }
        }
    }
}
